﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using MotoreDataBase;

namespace MvcSite.Models
{
    [Nome("Foto")]
    [NonQuery("SelectForAlbum", "SELECT * FROM Foto WHERE album = @id")]
    [NonQuery("DeleteFromAlbum", "DELETE FROM Foto WHERE album = @id")]
    public class Foto
    {

        [Nome("id_img")]
        [TableDefinition(TipoDatiDb.INT, 0, false, true, true)]
        public int IdImg { get; set; }
        [Nome("nome")]
        public string Nome { get; set; }
        [Nome("path")]    
        public string Path { get; set; }
        [Nome("data_upload")]    
        public DateTime Data_Upload { get; set; }
        [Nome("album")]
        public int Album { get; set; }
        [Nome("accesso")]
        public Accesso Accesso { get; set; }

        public Foto()
        {
        }

        public Foto(int IdImg, string Nome, string Path, DateTime Data_Upload, int Album, Accesso Accesso)
        {
            this.IdImg = IdImg;
            this.Nome = Nome;
            this.Path = Path;
            this.Data_Upload = Data_Upload;
            this.Album = Album;
            this.Accesso = Accesso;
        }

        public Foto(SqlDataReader reader)
        {
            this.IdImg = int.Parse(reader["id_img"].ToString());
            this.Nome = reader["nome"].ToString();
            this.Path = reader["path"].ToString();
            this.Data_Upload = DateTime.Parse(reader["data_upload"].ToString());
            this.Album = int.Parse(reader["album"].ToString());
            this.Accesso = (Accesso)Enum.Parse(typeof(Accesso), reader["accesso"].ToString());
        }
    }

    
    public enum Accesso
    {
        Private,
        Public
    }


    public class ElencoFoto
    {
        public int album { get; set; }
        public string[] elenco_id { get; set; }
        public string[] elenco_path { get; set; }
    }

}
